package com.optionexplorer.data;

import java.util.Date;

import com.optionexplorer.util.DateUtils;
import com.optionexplorer.util.NumberUtils;

public class CallOption extends StockOption {


	
	public CallOption( float stockPr,
			           String symb, 
					   Date expDate, 
					   float strikePrice, 
					   float premium, 
					   long volume, 
					   long openInt) {
		super(stockPr,symb,expDate,strikePrice,premium,volume,openInt);
		computeMetrics();
	}
	
	public String getType() {
		return StockOption.CALL_OPTION;
	}
	
	private void computeMetrics() {
		
		this.roe = NumberUtils.roundTwoDecimals((this.strikePrice - this.stockPrice + this.premium));
		this.percentRoe = NumberUtils.roundTwoDecimals((this.roe / (this.stockPrice - this.premium))*100);
		this.downBuf = this.premium;
		this.percentDownBuf = NumberUtils.roundTwoDecimals((this.premium / this.stockPrice)*100);
		
		this.remDays = DateUtils.getDaysRemaining(this.getExpirationDate());
		this.annualYield = NumberUtils.roundTwoDecimals(this.percentRoe * 365/remDays);
		this.annualDownBuf = NumberUtils.roundTwoDecimals(this.percentDownBuf * 365/remDays);
		
		
		return;
	}
	
	public String printAdditionalMetrics() {
		
		StringBuilder sb = new StringBuilder();
		sb.append(this.roe + "\t");
		sb.append(this.percentRoe + "%\t");
		sb.append(this.downBuf + "\t");
		sb.append(this.percentDownBuf + "%\t");
		sb.append(this.remDays + "\t");
		sb.append(this.annualYield + "%\t");
		
		return sb.toString();
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
